<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>投诉管理系统</title>
  <style>
    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      margin: 0;
      padding: 0;
      background: linear-gradient(135deg, #6a11cb, #2575fc);
      color: #333;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    .container {
      width: 90%;
      max-width: 600px;
      background: #fff;
      padding: 2rem;
      border-radius: 10px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    h1 {
      text-align: center;
      color: #444;
      margin-bottom: 1.5rem;
    }
    .form-group {
      margin-bottom: 1rem;
    }
    .form-group label {
      display: block;
      margin-bottom: 0.5rem;
      font-weight: bold;
    }
    .form-group input, .form-group textarea {
      width: 100%;
      padding: 0.75rem;
      border: 1px solid #ddd;
      border-radius: 5px;
      font-size: 1rem;
    }
    .form-group textarea {
      resize: vertical;
      height: 100px;
    }
    .form-group button {
      padding: 0.75rem 1.5rem;
      background: #28a745;
      color: #fff;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      font-size: 1rem;
      transition: background 0.3s ease;
    }
    .form-group button:hover {
      background: #218838;
    }
    .list-group {
      list-style-type: none;
      padding: 0;
    }
    .list-group-item {
      padding: 1rem;
      border: 1px solid #ddd;
      border-radius: 5px;
      margin-bottom: 0.5rem;
      background: #f9f9f9;
      transition: transform 0.2s ease;
    }
    .list-group-item:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
    .button-group {
      display: flex;
      gap: 0.5rem;
      margin-top: 1rem;
    }
    .button-group button {
      flex: 1;
    }
    .hidden {
      display: none;
    }
  </style>
</head>
<body>
<div class="container">
  <h1>投诉管理系统</h1>

  <!-- 登录注册界面 -->
  <div id="login-register">
    <h2>登录/注册</h2>
    <form id="loginForm">
      <div class="form-group">
        <label for="username">用户名:</label>
        <input type="text" id="username" name="username" required>
      </div>
      <div class="form-group">
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required>
      </div>
      <div class="button-group">
        <button type="submit">登录</button>
        <button type="button" onclick="showRegisterForm()">注册</button>
      </div>
    </form>
    <form id="registerForm" class="hidden">
      <div class="form-group">
        <label for="regUsername">用户名:</label>
        <input type="text" id="regUsername" name="regUsername" required>
      </div>
      <div class="form-group">
        <label for="regPassword">密码:</label>
        <input type="password" id="regPassword" name="regPassword" required>
      </div>
      <div class="button-group">
        <button type="submit">注册</button>
        <button type="button" onclick="showLoginForm()">返回登录</button>
      </div>
    </form>
  </div>

  <!-- 投诉方界面 -->
  <div id="complainant-interface" class="hidden">
    <h2>投诉方界面</h2>
    <button onclick="showComplaintForm()">发送投诉邮件</button>
    <ul id="complaintList" class="list-group"></ul>
  </div>

  <!-- 发送投诉邮件界面 -->
  <div id="complaint-form" class="hidden">
    <h2>发送投诉邮件</h2>
    <form id="complaintForm">
      <div class="form-group">
        <label>
          <input type="radio" name="anonymous" value="true" onclick="toggleComplainantField()"> 匿名
        </label>
        <label>
          <input type="radio" name="anonymous" value="false" onclick="toggleComplainantField()" checked> 不匿名
        </label>
      </div>
      <div class="form-group" id="complainantField">
        <label for="complainant">投诉人:</label>
        <input type="text" id="complainant" name="complainant">
      </div>
      <div class="form-group">
        <label for="complaintObject">投诉对象:</label>
        <input type="text" id="complaintObject" name="complaintObject" required>
      </div>
      <div class="form-group">
        <label for="complaintTitle">投诉标题:</label>
        <input type="text" id="complaintTitle" name="complaintTitle" required>
      </div>
      <div class="form-group">
        <label for="complaintContent">投诉内容:</label>
        <textarea id="complaintContent" name="complaintContent" required></textarea>
      </div>
      <div class="button-group">
        <button type="submit">发送</button>
        <button type="button" onclick="hideComplaintForm()">取消</button>
      </div>
    </form>
  </div>

  <!-- 投诉机构界面 -->
  <div id="complaint-agency-interface" class="hidden">
    <h2>投诉机构界面</h2>
    <ul id="agencyComplaintList" class="list-group"></ul>
  </div>
</div>

<script>
  function showRegisterForm() {
    document.getElementById('loginForm').classList.add('hidden');
    document.getElementById('registerForm').classList.remove('hidden');
  }

  function showLoginForm() {
    document.getElementById('registerForm').classList.add('hidden');
    document.getElementById('loginForm').classList.remove('hidden');
  }

  function toggleComplainantField() {
    const complainantField = document.getElementById('complainantField');
    const anonymous = document.querySelector('input[name="anonymous"]:checked').value === 'true';
    complainantField.style.display = anonymous ? 'none' : 'block';
  }

  function showComplaintForm() {
    document.getElementById('complaint-form').classList.remove('hidden');
  }

  function hideComplaintForm() {
    document.getElementById('complaint-form').classList.add('hidden');
  }

  // 模拟登录
  document.getElementById('loginForm').addEventListener('submit', function(event) {
    event.preventDefault();
    document.getElementById('login-register').classList.add('hidden');
    document.getElementById('complainant-interface').classList.remove('hidden');
  });

  // 模拟注册
  document.getElementById('registerForm').addEventListener('submit', function(event) {
    event.preventDefault();
    alert('注册成功，请登录');
    showLoginForm();
  });

  // 模拟发送投诉
  document.getElementById('complaintForm').addEventListener('submit', function(event) {
    event.preventDefault();
    // const complainant = document.getElementById('complainant').value;
    // const complaintObject = document.getElementById('complaintObject').value;
    const complaintTitle = document.getElementById('complaintTitle').value;
    // const complaintContent = document.getElementById('complaintContent').value;
    // const anonymous = document.querySelector('input[name="anonymous"]:checked').value === 'true';

    const complaintItem = document.createElement('li');
    complaintItem.className = 'list-group-item';
    // complaintItem.innerHTML = `
    //             <strong>投诉对象:</strong> ${complaintObject}<br>
    //             <strong>投诉标题:</strong> ${complaintTitle}<br>
    //             <strong>投诉内容:</strong> ${complaintContent}<br>
    //             <strong>投诉人:</strong> ${anonymous ? '匿名' : complainant}
    //         `;
    complaintItem.innerHTML = `
                <tr><td>${complaintTitle}</td><td><form><input type="submit"></form></td></tr>
            `;
    document.getElementById('complaintList').appendChild(complaintItem);
    hideComplaintForm();
  });
</script>
</body>
</html>